package ru.spb.nicetu.altx.mnemo.palette.core;

import java.util.List;

import org.eclipse.core.runtime.IAdaptable;

import ru.spb.nicetu.altx.mnemo.node.factory.INodeFactory;

public class FunctionDescriptor extends ItemElementDescriptor implements IAdaptable{

  private List<FuncParamDescriptor> inputParams;
  private List<FuncParamDescriptor> outputParams;
  private List<FuncParamDescriptor> settingParams;
  
  private INodeFactory factory;
  
  public FunctionDescriptor(String name, List<FuncParamDescriptor> inputParams,
      List<FuncParamDescriptor> outputParams,
      List<FuncParamDescriptor> settingParams) {
    super(name);
    this.inputParams = inputParams;
    this.outputParams = outputParams;
    this.settingParams = settingParams;
  }

  public List<FuncParamDescriptor> getInputParams() {
    return inputParams;
  }

  public void setInputParams(List<FuncParamDescriptor> inputParams) {
    this.inputParams = inputParams;
  }

  public List<FuncParamDescriptor> getOutputParams() {
    return outputParams;
  }

  public void setOutputParams(List<FuncParamDescriptor> outputParams) {
    this.outputParams = outputParams;
  }

  public List<FuncParamDescriptor> getSettingParams() {
    return settingParams;
  }

  public void setSettingParams(List<FuncParamDescriptor> settingParams) {
    this.settingParams = settingParams;
  }
  
  public void setNodeFactory(INodeFactory factory){
    this.factory = factory;
  }
  
  public INodeFactory getNodeFactory(){
    return this.factory;
  }

  public Object getAdapter(Class adapter) {
    // TODO Auto-generated method stub
    return null;
  }
  
  @Override
  public int hashCode() {
    int hash = 0;
    hash += getName().hashCode();
    
    for (FuncParamDescriptor desc: inputParams){
      hash+=desc.hashCode();
    }
    for (FuncParamDescriptor desc: outputParams){
      hash+=desc.hashCode();
    }
    for (FuncParamDescriptor desc: settingParams){
      hash+=desc.hashCode();
    }
    return hash;
  }
  
  @Override
  public boolean equals(Object obj) {
    if (obj.getClass() != this.getClass())
      return false;
    
    return (obj.hashCode() == this.hashCode());
  }
}
